from fastapi import FastAPI, Query
from typing import List

app = FastAPI(title="城市旅游服务")

SUPPORTED_CITIES = ["北京", "上海", "广州", "深圳", "成都", "杭州"]
TOUR_SPOTS = {
    "北京": ["故宫", "长城", "颐和园"],
    "上海": ["外滩", "东方明珠", "豫园"],
    "广州": ["广州塔", "白云山", "陈家祠"],
    "深圳": ["世界之窗", "欢乐谷", "大梅沙"],
    "成都": ["宽窄巷子", "锦里", "大熊猫基地"],
    "杭州": ["西湖", "灵隐寺", "千岛湖"]
}

@app.get("/cities", response_model=List[str])
def get_cities():
    """查询支持的城市列表"""
    return SUPPORTED_CITIES

@app.get("/tourspots")
def get_tour_spots(city: str = Query(..., description="城市名")):
    """查询指定城市的旅游地址推荐（模拟数据）"""
    if city not in TOUR_SPOTS:
        return {"error": "不支持该城市"}
    return {"city": city, "tour_spots": TOUR_SPOTS[city]}
